<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实现构造函数的继承</title>
</head>
<body>
    
</body>
</html>
<script>
    //请求数据
    function Request(){
        this.get = function(params = {}){
        //组合请求参数
            let option = Object.keys(params)
            .map(key => key + '=' + params[key]).join('&');
            return `获取数据API:${this.url}?${option}`;
        };
    }

    //文章控制器
    //请求数据的时候需要组合成 https://www.xiaobangcai.com?id=1&title=hdcms
    function Article(){
        this.url = "https://www.xiaobangcai.com/article/index";
        Request.apply(this,[]);
    }

    //用户控制器
    function User(){
        this.url = "https://www.xiaobangcai.com/user/index";
        Request.call(this);
    }


    // let hd = new Article();
    // let user = new User({user_id:1,name:'liuhao'});
    // console.log(hd.get({id:1,name:'六号'}))

    let user = new User();
    console.log(user.get({user_id:1,name:'liuhao'}))


    </script>